/**
 * 
 */
package signGrammar.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

public class CViewNonterminalButton extends JButton {
	private static final long serialVersionUID = 1L;

	public interface INonterminalListener {
		public void nonterminalClicked(String nameID);
	}
	
	public static class CNonterminalListenerAdapter implements ActionListener {
		private INonterminalListener variableListener;
		public CNonterminalListenerAdapter(INonterminalListener variableListener) {
			this.variableListener = variableListener;
		}
		@Override public void actionPerformed(ActionEvent e) {
			variableListener.nonterminalClicked( e.getActionCommand() );
		}		
	}	
	
	public CViewNonterminalButton(String varName, String screenName, INonterminalListener listener) {
		setText(screenName);
		setActionCommand(varName);
		addActionListener( new CNonterminalListenerAdapter( listener ) );
	}
}